package com.bf.xpdd.util;

import java.util.Date;
import java.util.Map;

import com.bf.xpdd.domain.ActivitySettingBean;

public class SettingUtility
{
	/**
	 * 成成默认的模板
	 */
	public static ActivitySettingBean createDefaultSetting()
	{
		ActivitySettingBean bean = new ActivitySettingBean();
		bean.setaI(1);
		bean.setBaseLine(0d);
		bean.setFirstDialogue("firstDialogue");
		bean.setSecondDialogue("secondDialogue");
		bean.setThridDialogue("thridDialogue");
		bean.setForthDialogue("forthDialogue");
		bean.setLastModifyTime(new Date());
		bean.setMaxCount(3);
		bean.setName("demo");
		bean.setNick("nick");
		return bean;
	}
	/**
	 * 从map参数中获取活动参数模板
	 */
	public static ActivitySettingBean getSettingFromParamters(Map<String, String> map)
	{
		ActivitySettingBean setting = null;
		try
		{
			setting = new ActivitySettingBean();
			setting.setName(map.get("setName"));
			String tmp = map.get("setPrice");
			setting.setBaseLine(Double.parseDouble(tmp));
			tmp = map.get("maxCount");
			setting.setMaxCount(Integer.parseInt(tmp));
			tmp = map.get("amount");
			setting.setaI(Integer.parseInt(tmp));
			setting.setFirstDialogue(map.get("firstDialog"));
			setting.setSecondDialogue(map.get("secondDialog"));
			setting.setThridDialogue(map.get("thirdDialog"));
			setting.setForthDialogue(map.get("forthDialog"));
			setting.setLastModifyTime(new Date());
		}
		catch (Exception e) 
		{
			e.printStackTrace();
		}
		return setting;
	}
}
